Skip to content

Propagate native exe exit codes from PowerShell - #23

Merged
TsekNet merged 1 commit into
mainfrom
exec-lastexitcode
Apr 12, 2026
Merged

TsekNet merged 1 commit into
mainfrom
exec-lastexitcode

Conversation

@TsekNet

@TsekNet TsekNet commented Apr 12, 2026

Copy link
Copy Markdown
Owner

Summary

Append ; if ($LASTEXITCODE) { exit $LASTEXITCODE } to every PowerShell -Command invocation. Without this, powershell.exe exits 0 when a native executable (msiexec, reg.exe, net.exe) fails, causing converge to treat a failed Apply as successful.

Safe for pure-cmdlet commands: $LASTEXITCODE is $null when no native exe has run, so the suffix is a no-op.

Test plan

  • go build ./... passes (Linux, macOS, Windows)
  • go test -race ./extensions/exec/ passes
  • Existing tests unaffected (suffix is invisible to cmdlet-only commands)

Ref #21

Append '; if ($LASTEXITCODE) { exit $LASTEXITCODE }' to every
PowerShell -Command invocation. Without this, powershell.exe exits 0
when a native executable (msiexec, reg.exe, net.exe) fails, causing
converge to treat a failed Apply as successful.

Safe for pure-cmdlet commands: $LASTEXITCODE is $null when no native
exe has run, so the suffix is a no-op.

Ref #21
@TsekNet
TsekNet merged commit f79e297 into main Apr 12, 2026
1 check passed
@TsekNet
TsekNet deleted the exec-lastexitcode branch April 12, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant